package com.goods.controller.business;

import com.goods.business.service.InStockService;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.InStockDetailVO;
import com.goods.common.vo.business.InStockVO;
import com.goods.common.vo.system.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 赵勇镔
 * @Time: 2021/6/9 10:50
 * @Description:
 */


@Api(tags = "业务模块-入库记录")
@RestController
@RequestMapping("/business/inStock")
public class InStockController {

    @Autowired
    private InStockService inStockService;

    @ApiOperation(value = "入库记录", notes = "物资入库列表")
    @GetMapping("/findInStockList")
    public ResponseBean<PageVO<InStockVO>> findInStockList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                           @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                           InStockVO inStockVO) {

        PageVO<InStockVO> pageVO = inStockService.findInStockList(pageNum,pageSize,inStockVO);
        return ResponseBean.success(pageVO);
    }


    @ApiOperation(value = "入库记录", notes = "物资明细列表")
    @GetMapping("/detail/{id}")
    public ResponseBean<InStockDetailVO>  detail(@RequestParam  Integer pageNum, @PathVariable Integer id) {

        InStockDetailVO inStockDetailVO = inStockService.detail(pageNum,id);
        return ResponseBean.success(inStockDetailVO);
    }

    @ApiOperation(value = "入库记录", notes = "物资明细列表添加回收站")
    @PutMapping("/remove/{id}")
    public ResponseBean  remove(@PathVariable Long id) {

        inStockService.remove(id);
        return ResponseBean.success();
    }

    @ApiOperation(value = "入库记录", notes = "物资明细列表回收站还原")
    @PutMapping("/back/{id}")
    public ResponseBean  back(@PathVariable Long id) {

        inStockService.back(id);
        return ResponseBean.success();
    }

    @ApiOperation(value = "入库记录", notes = "物资明细列表删除")
    @GetMapping("/delete/{id}")
    public ResponseBean  delete(@PathVariable Long id) {

        inStockService.delete(id);
        return ResponseBean.success();
    }

    @ApiOperation(value = "入库记录", notes = "入库信息保存")
    @PostMapping("/addIntoStock")
    public ResponseBean  addIntoStock(@RequestBody InStockVO inStockVO) {
        inStockService.addIntoStock(inStockVO);
        return ResponseBean.success();
    }

    @ApiOperation(value = "入库记录", notes = "入库信息审核通过")
    @PutMapping("/publish/{id}")
    public ResponseBean  publish(@PathVariable Long id) {
        inStockService.publish(id);
        return ResponseBean.success();
    }

}
